package com.isnmp.common.snmp.impl;

import java.util.Vector;

import net.percederberg.mibble.MibValueSymbol;

import org.snmp4j.PDU;
import org.snmp4j.Snmp;
import org.snmp4j.Target;
import org.snmp4j.event.ResponseEvent;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.Variable;
import org.snmp4j.smi.VariableBinding;

import com.isnmp.common.base.MyException;

public class RefreshAction {

    public static void reFresh(Object mibSystem, Snmp paramSnmp, Target paramTarget) throws MyException {
        try {
            String str1 = SNMPUtils.getMibOIDofClass(mibSystem.getClass());
            Object localObject1 = SNMPAPIImpl.getInstance().getMibSymbolByOid(str1);
            String str2 = SNMPUtils.getTableOrGroupIndexOID(mibSystem, (MibValueSymbol) localObject1);
            Class localClass = mibSystem.getClass();
            Vector localVector = SNMPUtils.getFieldsInMibNode(localClass, (MibValueSymbol) localObject1);
            PDU localPDU = new PDU();
            for (int i = 0; i < localVector.size(); i++) {
                Object localObject2 = (MibValueSymbol) localVector.get(i);
                String str3 = ((MibValueSymbol) localObject2).getValue().toString() + "." + str2;
                localPDU.add(new VariableBinding(new OID(str3)));
            }
            ResponseEvent localResponseEvent = paramSnmp.get(localPDU, paramTarget);
            SNMPUtils.checkSNMPErro(localResponseEvent);
            Object localObject2 = localResponseEvent.getResponse().getVariableBindings();
            for (int j = 0; j < ((Vector) localObject2).size(); j++) {
                VariableBinding localVariableBinding = (VariableBinding) ((Vector) localObject2).get(j);
                String str4 = localVariableBinding.getOid().toString();
                String str5 = ((MibValueSymbol) localObject1).getMib().getSymbolByOid(str4).getName();
                Variable localVariable = localVariableBinding.getVariable();
                if (localVariable.toString().equalsIgnoreCase("noSuchObject"))
                    throw new MyException(Messages.getString("RefreshAction.0") + str5);
                SNMPUtils.setFieldValue(mibSystem, str5, localVariable);
            }
        } catch (Exception localException) {
            Object localObject1 = Messages.getString("RefreshAction.3") + mibSystem.getClass().getName() + Messages.getString("RefreshAction.4") + paramTarget.getAddress() + Messages.getString("RefreshAction.5") + localException.getMessage();
            throw new MyException((String) localObject1);
        }
    }

    public static void main(String[] paramArrayOfString) {
        new RefreshAction();
    }
}